package com.example.database;

import java.util.ArrayList;
import java.util.List;

import com.exanple.data.Activeinfo;
import com.exanple.data.ChatMsgEntity;

import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

public class ActiveDbManager {
	private DbHelper activehelper;  
    private SQLiteDatabase activedb;  
    public ActiveDbManager(Context context) {  
        activehelper = new DbHelper(context);  
        //因为getWritableDatabase内部调用了mContext.openOrCreateDatabase(mName, 0, mFactory);  
        //所以要确保context已初始化,我们可以把实例化DBManager的步骤放在Activity的onCreate里  
        activedb = activehelper.getWritableDatabase();  
    }  
   
  
	public void addactive(Activeinfo active) {
		// TODO Auto-generated method stub
		activedb.beginTransaction();  //开始事务  
        try {  
              
        	activedb.execSQL("INSERT INTO activeinfo (activename,currentname,leader,parter,location,allip,activetime) VALUES( ?, ?, ?, ?, ?, ?, ?)", new Object[]{active.getActivename(),active.getCurrentname(),active.getLeader(),active.getParter(),active.getLocation(),active.getAllip(),active.getActivetime()});  
             
        	activedb.setTransactionSuccessful();  //设置事务成功完成  
        } finally {  
        	activedb.endTransaction();    //结束事务  
        }  
	}
	  
}
